<?php
class Dept
{
    public static function get($id)
    {
        return Db::get(__CLASS__)->select()->where(array('id'=>$id))->getOne();
    }

    public static function getList($where=array(), $s=0, $l=0)
    {
        return Db::get(__CLASS__)->select()->where($where)->order('sort ASC,id ASC')->limit($s, $l)->hkey('id')->getAll();
    }
	
	public static function getHashList($where=''){
        return Db::get(__CLASS__)->select('name')->where($where)->order('sort ASC,id ASC')->hkey('id')->getCols();
	}
	
    public static function count($where=array())
    {
        return Db::get(__CLASS__)->count()->where($where)->getCol();
    }

    public static function add($data)
    {
		return Db::get(__CLASS__)->insert($data)->exec() ? Db::get(__CLASS__)->insertId() : false;
    }
    public static function update($id, $data)
    {
        return Db::get(__CLASS__)->update($data)->where(array('id'=>$id))->exec();
    }

	static function getTitle($id)
	{
		if(!$id) {
			return false;
		}
		return Db::get(__CLASS__)->select('name')->where(array('id'=>$id))->getCol();
	}
	

}
?>
